﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 共享单车管理系统.star
{
    public partial class Person : Form
    {
        public Person()
        {
            InitializeComponent();
        }

        private void Person_Load(object sender, EventArgs e)
        {
            DB.GetCn();
            string str = "select * from Employee where  EmployeeID='" + Login.EmployeeID + "'";
            DataTable dt = DB.GetDataSet(str);
            txtid.Text = dt.Rows[0][0].ToString();
            txtname.Text = dt.Rows[0][1].ToString();
            txtposition.Text = dt.Rows[0][2].ToString();
            date101.Value = Convert.ToDateTime(dt.Rows[0][3]);
            txtphone.Text = dt.Rows[0][5].ToString();
            txthobby.Text = dt.Rows[0][9].ToString();
            txtadder.Text = dt.Rows[0][7].ToString();
            txtemails.Text = dt.Rows[0][4].ToString();
            txtdepartmentid.Text = dt.Rows[0][6].ToString();
            txtschool.Text = dt.Rows[0][8].ToString();
        }

        private void buttonok_Click(object sender, EventArgs e)
        {
            DB.GetCn();
            string str="update Employee set EmployeeName='"
                +txtname.Text+"',Position='"
                + txtposition.Text + "',HireDate='"
                +date101.Value + "',Address='"
                +txtadder.Text + "',Email='"
                +txtemails.Text + "',DepartmentID='"
                +txtdepartmentid.Text + "',GraduatedFrom='"
                +txtschool.Text + "', hobby='"
                + txthobby.Text + "' where EmployeeID = '" + txtid.Text + "'";

            DB.sqlEx(str);
            MessageBox.Show("修改成功");

        }

        private void buttoncance_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
